home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / dviware / dvitovdu32 / src / pascal / vis550vdu.p < prev    next >
Text File  |  1991-11-10  |  6KB  |  193 lines

  1. (* VDU routines for a VIS550 terminal. *)
  2.  
  3. #include 'globals.h';
  4. #include 'screenio.h';
  5. #include 'vdu.h';
  6. #include 'tek4010vdu.h';
  7.  
  8. (******************************************************************************)
  9.  
  10. PROCEDURE StartText;
  11.  
  12. (* We are about to draw text in dialogue region. *)
  13.  
  14. BEGIN
  15. TEK4010StartText;
  16. END; (* StartText *)
  17.  
  18. (******************************************************************************)
  19.  
  20. PROCEDURE MoveAbs (row, col : INTEGER);
  21.  
  22. (* Move cursor to given screen position. *)
  23.  
  24. BEGIN
  25. WriteChar(ESC); WriteChar('[');
  26. WriteInt(row);
  27. WriteChar(';');
  28. WriteInt(col);
  29. WriteChar('H');
  30. END; (* MoveAbs *)
  31.  
  32. (******************************************************************************)
  33.  
  34. PROCEDURE MoveToTextLine (line : INTEGER);
  35.  
  36. (* Move current position to start of given line. *)
  37.  
  38. BEGIN
  39. WriteChar(CAN);
  40. MoveAbs(line,1);
  41. END; (* MoveToTextLine *)
  42.  
  43. (******************************************************************************)
  44.  
  45. PROCEDURE ClearTextLine (line : INTEGER);
  46.  
  47. (* Erase given line; note that DVItoVDU does not assume anything about the
  48.    current position at the end of this routine.
  49. *)
  50.  
  51. BEGIN
  52. WriteChar(CAN);
  53. MoveAbs(line,1);
  54. WriteChar(ESC);
  55. WriteString('[K');   (* erase to end of line *)
  56. END; (* ClearTextLine *)
  57.  
  58. (******************************************************************************)
  59.  
  60. PROCEDURE ClearScreen;
  61.  
  62. BEGIN
  63. WriteChar(CAN);
  64. WriteChar(ESC);
  65. WriteString('[2J');   (* erase all alphanumerics *)
  66. TEK4010ClearScreen;
  67. END; (* ClearScreen *)
  68.  
  69. (******************************************************************************)
  70.  
  71. PROCEDURE StartGraphics;
  72.  
  73. (* We are about to draw in window region. *)
  74.  
  75. BEGIN
  76. TEK4010StartGraphics;
  77. END; (* StartGraphics *)
  78.  
  79. (******************************************************************************)
  80.  
  81. PROCEDURE LoadFont (fontname : string;
  82.                     fontsize : INTEGER;
  83.                     mag, hscale, vscale : REAL);
  84.  
  85. BEGIN
  86. TEK4010LoadFont(fontname,fontsize,mag,hscale,vscale);
  87. END; (* LoadFont *)
  88.  
  89. (******************************************************************************)
  90.  
  91. PROCEDURE ShowChar (screenh, screenv : INTEGER;
  92.                     ch : CHAR);
  93.  
  94. (* The TEK4010 Terse mode characters on the VIS550 need to be dragged down
  95.    so that any descenders will be below the baseline represented by screenv.
  96. *)
  97.  
  98. BEGIN
  99. screenv := screenv + dragdown;
  100. IF screenv > 779 THEN
  101.    TEK4010ShowChar(screenh, 779, ch)   (* drag down as far as possible *)
  102. ELSE
  103.    TEK4010ShowChar(screenh, screenv, ch);
  104. END; (* ShowChar *)
  105.  
  106. (******************************************************************************)
  107.  
  108. PROCEDURE ShowRectangle (screenh, screenv,          (* top left pixel *)
  109.                          width, height : INTEGER;   (* size of rectangle *)
  110.                          ch : CHAR);                (* black pixel *)
  111.  
  112. (* Display the given rectangle. *)
  113.  
  114. VAR pos : INTEGER;
  115.  
  116. BEGIN
  117. IF height = 1 THEN BEGIN            (* show row vector *)
  118.    pos := 779 - screenv;
  119.    WriteChar(GS);
  120.    SendXY(screenh,pos);             (* move cursor to start of row *)
  121.    SendXY(screenh+width-1,pos);     (* draw vector to end of row *)
  122. END
  123. ELSE IF width = 1 THEN BEGIN        (* show column vector *)
  124.    pos := 779 - screenv;
  125.    WriteChar(GS);
  126.    SendXY(screenh,pos);             (* move cursor to start of column *)
  127.    SendXY(screenh,pos-height+1);    (* draw vector to end of column *)
  128. END
  129. ELSE BEGIN
  130.    (* assume height and width > 1; draw and fill rectangle *)
  131.    pos := 779 - (screenv+height-1);
  132.    WriteChar(ESC);         WriteChar('/');
  133.    WriteInt(screenh);      WriteChar(';');   (* left *)
  134.    WriteInt(pos);          WriteChar(';');   (* bottom *)
  135.    WriteInt(width-1);      WriteChar(';');
  136.    WriteInt(height+1);     WriteChar('y');
  137.    (* Note that there are a few problems with this command:
  138.       - we need to subtract 1 from width.  While this prevents exceeding the
  139.         right edge (reason unknown), it causes missing pixel columns.
  140.       - we need to ADD 1 to height to avoid missing pixel rows.
  141.       - the smallest rectangle drawn is 2 by 2.
  142.       - the new cursor position is undefined.
  143.       These funnies are outweighed by the improved efficiency in drawing large
  144.       rectangles.
  145.    *)
  146.    havesentxy := FALSE;   (* need to re-synch cursor position *)
  147. END;
  148. END; (* ShowRectangle *)
  149.  
  150. (******************************************************************************)
  151.  
  152. PROCEDURE ResetVDU;
  153.  
  154. BEGIN
  155. WriteChar(CAN);
  156. END; (* ResetVDU *)
  157.  
  158. (******************************************************************************)
  159.  
  160. PROCEDURE InitVDU;
  161.  
  162. (* The dialog region will be the top 4 text lines in VT100 mode:
  163.       Line 1 = DVI status line,
  164.       Line 2 = window status line,
  165.       Line 3 = message line,
  166.       Line 4 = command line.
  167.    The window region will be text lines 5 to 33 in VT100 mode.
  168. *)
  169.  
  170. BEGIN
  171. InitTEK4010VDU;
  172. DVIstatusl    := 1;      (* DVItoVDU assumes top text line = 1 *)
  173. windowstatusl := 2;
  174. messagel      := 3;
  175. commandl      := 4;
  176. bottoml       := 33;     (* also number of text lines on screen *)
  177. (* The above values assume the VIS550 is in VT100 mode;
  178.    the following values assume it is emulating a Tektronix 4010.
  179.    Note that windowv must be given a value using DVItoVDU's coordinate scheme
  180.    where top left pixel is (0,0).
  181. *)
  182. windowv  := 92;          (* approx. height in TEK4010 pixels of 4 text lines
  183.                             i.e. ~ 4 * 780/34 *)
  184. windowh  := 0;
  185. windowht := 780-windowv;
  186. windowwd := 1024;
  187.  
  188. WriteChar(GS);
  189. WriteChar(ESC);
  190. WriteChar('@');          (* solid fill for rectangular draw and fill *)
  191. WriteChar(CAN);
  192. END; (* InitVDU *)
  193.